<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据处理</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
<link href="<%=path %>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="<%=path %>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="<%=path %>/hplus/css/animate.min.css" rel="stylesheet">
<link href="<%=path %>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
    <style>
        .col-sm-1{
            padding-right: 0;
        }
        .label1{
                line-height: 2.1;
        	}
        .pie1{
    		margin-top: 20px;
    		 height: 500px;
    		 margin-left:18px;
    		 margin-right:18px;
        }
        .label2{
        	height: 34px;
   text-align-last: center;
    width: 50px;
    margin-left: -243px;
    line-height: 20px;
    background-color: #EAEAEA;
        }
        .label3{
        height: 34px;
   text-align-last: center;
    width: 50px;
    margin-left: -250px;
    line-height: 20px;
    background-color: #EAEAEA;
        }
        .order{
        	   line-height: 2;
        }
        input.uploadFile{
            position: absolute;
            opacity: 0;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            line-height: 0;
            padding-left: 0;
            margin-left: 0;
        }
        .uploadBtn{
            width: 60px;
            display: inline-block;
            background: #1ab394;
            color: #fff;
            border-radius: 3px;
            height: 36px;
            line-height: 36px;
            border: none;
            font-size: 14px;
        }
        .s_address{
            height: 340px;
            background:#eee;
        }
        .red{
            color: red;
            margin-right: 5px;
        }
		body{
			font-size:14px;
			
		}
		ol{
  		list-style:none;
  	}
  	li{
  		list-style:none;
  	}
  	.tb{
  		margin-top:20px;
  	}
  	#tb1 td{
  		width:200px;
  		height:48px;
  	}
JSON
body {font-size: 14px;padding: 20px;}
.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
form>div.row{margin-bottom: 16px;}
a.btn-rounded{margin-right: 16px;}
a:hover{
	background-color:red;
	color:red;
}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
     <div class="tabs-container">
		    <ul class="nav nav-tabs">
		                <li class="active"><a style="margin-left: 500px;" data-toggle="tab" href="#tab-0" aria-expanded="true"onclick="getDataList()">数据匹配</a>
		                </li>
		                <li class=""><a data-toggle="tab" href="#tab-1" aria-expanded="false" onclick="getDataList1()">审核上传</a>
		                </li>
		                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false" onclick="getDataList2()">上传成功</a>
		                </li>
		                <li class=""><input onclick="getDataList3()" type="button" class="uploadBtn" style="margin-left: 500px;" data-toggle="tab" href="#tab-3" aria-expanded="false" value="回收站">
		                </li>
		     </ul>
			<div class="tab-content">
			     <div class="ibox-content tab-pane active" id="tab-0" style="height:100%;">
					 <div class="row col-sm-1">
					 <form method="post" class="form-horizontal" id='share_image' enctype='multipart/form-data'>
					 	<button class="uploadBtn" style="margin-left: 10px">上传
                        <input type="file" id="inputfile" name="filepath"
                               style="margin-top: -38px;  margin-left: -5px;width: 60px;filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;">
                   		 </button>
                   	 </form>
					 </div>	
			<div class="row">
				 <input type="button" class="uploadBtn" id="batch" onclick="batchMatching()" value="批量匹配" style="margin-left: 130px;width: 170px;display:none;">	
			</div>	 
				<div class="row" id="marryTable">
					<div class="m_xpages" style="float: right;margin:0;padding: 2px 0 1px 0;">
							<div class="mian" style="margin-left: 400px;">
								<span>显示行数</span> <select><option>10</option>
									<option>20</option>
									<option>50</option>
									</select> <span>共0条</span> <span>1/1页</span><!--  <a
									href="javascript:;" class="prev">上一页</a> <a href="javascript:;"
									class="next">下一页</a> <span>前往</span> <input type="text" value="1"
									class="text"> <span>页</span> -->
							</div>
					</div>
					<div style="float:left; width:100%">
						<table class="table table-bordered">
							<thead>
								<tr>
									<th style="    width: 50px;">序号</th>
									<th>商品编码</th>
									<th>条形码</th>
									<th>商品名/通用名</th>
									<th>规格</th>
									<th>国药准字</th>
									<th>生产企业</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody id="tbody">
								
							</tbody>
						</table>
					</div>	      		 
				 </div>
				 <div class="row">
				 	<div class="col-sm-4"></div>
					 <input type="button" id="ignore" class="uploadBtn" onclick="ignoreAll()" value="忽略本页"   style="margin-left: 130px;width: 170px;display:none;">	
				</div>
				 <div class="row"  style="margin-left: 500px; ">					 
					 	<div id="importData" style="display:none;">
					 		<p style="color:blue;">注：标红字段为必有字段，该字段都不存在的数据不予导入显示</p>
					 		<table class="table table-bordered" id="tb1" style="width:400px;text-align: center;">
					 			<thead>
					 				<tr>
					 				<th style="text-align: center;">标准字段</th>
					 				<th style="text-align: center;">导入字段</th>
					 				</tr>	
					 			</thead>
					 			<tbody>
					 				<tr>
					 					<td style="color:red;">商品名</td>
					 					<td >
					 					<select id="name" class=' form-control' style=' height: 100%; width: 100%;'></select>
					 					</td>
					 				</tr>
					 				<tr>
					 					<td style="color:red;">通用名</td>
					 					<td>
					 					<select id="commonName" class=' form-control' style=' height: 100%; width: 100%;'></select>					 					
					 					</td>
					 				</tr>
					 				<tr>
					 					<td style="color:red;">规格</td>
					 					<td >					
					 					 	<select id="spec" class=' form-control' style=' height: 100%; width: 100%;'></select>					 					
					 					</td>
					 				</tr>
					 				<tr>
					 					<td style="color:red;">生产企业</td>
					 					<td>
					 					<select id="companyName" class=' form-control' style=' height: 100%; width: 100%;'></select>					 					
					 					</td>
					 				</tr>
					 				<tr>
					 					<td>条形码</td>
					 					<td>
					 					<select id="barCode" class=' form-control' style=' height: 100%; width: 100%;'></select>					 										 					
					 					</td>
					 				</tr>
					 				<tr>
					 					<td>国药准字</td>
					 					<td>
					 					<select id="numberApproval" class=' form-control' style=' height: 100%; width: 100%;'></select>					 					
					 					</td>
					 				</tr>
					 				<tr>
					 					<td>商品编码</td>
					 					<td>
					 					<select id="goodsId" class=' form-control' style=' height: 100%; width: 100%;'></select>					 					
					 					</td>
					 				</tr>
					 			</tbody>
					 		</table>
					 		<input type="button" class="uploadBtn" id="commit" value="确认" style="margin-left: 130px;width: 170px;">	
					 	</div>					 	
					 </div>
				 </div>
				 <div class="ibox-content tab-pane" id="tab-1">
				 	<div class="row">
				 		<input type="button" class="uploadBtn" name="check" value="全选" onclick="checkAll()" style="width: 50px;">		
				 	</div>
				 	<div class="row" id="marryTable1" >
					<div class="m_xpages1" style="float: right;margin:0;padding: 2px 0 1px 0;">
							<div class="mian" style="margin-left: 400px;">
								<span>显示行数</span> <select><option>10</option>
									<option>20</option>
									<option>50</option>
									</select> <span>共0条</span> <span>1/1页</span><!--  <a
									href="javascript:;" class="prev1">上一页</a> <a href="javascript:;"
									class="next1">下一页</a> <span>前往</span> <input type="text" value="1"
									class="text1"> <span>页</span> -->
							</div>
					</div>
					<div style="float:left; width:100%">
						<table class="table table-bordered">
							<thead>
								<tr>
									<th style="    width: 50px;">序号</th>
									<th>商品编码</th>
									<th>条形码</th>
									<th>商品名/通用名</th>
									<th>规格</th>
									<th>国药准字</th>
									<th>生产企业</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody id="tbody1">
								
							</tbody>
						</table>						
					</div>	
					<div class="row">
							<div class="col-sm-3"></div>
							<input type="button" class="uploadBtn" onclick="uploadAll()" value="批量上传" style="margin-left: 130px;width: 120px;">	
					 		<input type="button" class="uploadBtn" onclick="cancelAll()" value="撤销本页" style="margin-left: 130px;width: 120px;">	
					 	</div>      		 
				 </div>
				 </div>
				 <div class="ibox-content tab-pane" id="tab-2">
				 	<div class="row" id="marryTable2" >
						<div class="m_xpages2" style="float: right;margin:0;padding: 2px 0 1px 0;">
								<div class="mian" style="margin-left: 400px;">
									<span>显示行数</span> <select><option>10</option>
										<option>20</option>
										<option>50</option>
										</select> <span>共0条</span> <span>1/1页</span><!--  <a
										href="javascript:;" class="prev2">上一页</a> <a href="javascript:;"
										class="next2">下一页</a> <span>前往</span> <input type="text" value="1"
										class="text2"> <span>页</span> -->
								</div>
						</div>
						<div style="float:left; width:100%">
							<table class="table table-bordered">
								<thead>
									<tr>
										<th style="    width: 50px;">序号</th>
										<th>商品编码</th>
										<th>条形码</th>
										<th>商品名/通用名</th>
										<th>规格</th>
										<th>国药准字</th>
										<th>生产企业</th>
									</tr>
								</thead>
								<tbody id="tbody2">
									
								</tbody>
							</table>
						</div>	     		 
					 </div>
				 </div>
				 <div class="ibox-content tab-pane" id="tab-3">
					 <div class="row" id="marryTable3" >
						<div class="m_xpages3" style="float: right;margin:0;padding: 2px 0 1px 0;">
								<div class="mian" style="margin-left: 400px;">
									<span>显示行数</span> <select><option>10</option>
										<option>20</option>
										<option>50</option>
										</select> <span>共0条</span> <span>1/1页</span> <!-- <a
										href="javascript:;" class="prev3">上一页</a> <a href="javascript:;"
										class="next3">下一页</a> <span>前往</span> <input type="text" value="1"
										class="text3"> <span>页</span> -->
								</div>
						</div>
						<div style="float:left; width:100%">
							<table class="table table-bordered">
								<thead>
									<tr>
										<th style="    width: 50px;">序号</th>
										<th>商品编码</th>
										<th>条形码</th>
										<th>商品名/通用名</th>
										<th>规格</th>
										<th>国药准字</th>
										<th>生产企业</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody id="tbody3">
									
								</tbody>
							</table>
						</div>
						<div class="row">
							<div class="col-sm-4"></div>
						 		<input type="button" class="uploadBtn" value="删除本页" onclick="deleteDialog()"style="margin-left: 130px;width: 170px;">	
						 	</div> 	
					    </div>		 
					 </div>
				 </div>
		    </div>
		</div>
	</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="<%=path %>/hplus/js/content.min.js?v=1.0.0"></script>
    <script src="<%=path %>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=path %>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=path %>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=path %>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=path %>/hplus/js/plugins/nouslider/jquery.nouislider.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=path %>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=path %>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.6.1/echarts.min.js"></script>
 	<script src="<%=path%>/hplus/js/plugins/cropper/cropper.min.js"></script>   
    <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="<%=path%>/hplus/js/demo/form-advanced-demo.min.js"></script>
	<script src="<%=path%>/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/jquery-form.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
	<script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>	
	<script>
    var access_token=$.cookie('access_token');
   	var cid=$.cookie('cid');
   	var uid=$.cookie('uid');
   	var id=getQueryString("id");
   	var path="";
    var startIndex = 0;
    var pageSize = 10;
    var currentPage = 1;
    var pageCount = 0;
   <%--  function insert(){
    	var insertUrl="<%=path%>/ser/auditingMedicine/insertTable";
    	$.post(insertUrl,function(data){
    		console.log(data);
    	});
    } --%>
    $(function(){
    	$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
    });
    $("#inputfile").change(function(){
		var filePath=$("input[name='filepath']").val();
		var extStart = filePath.lastIndexOf(".");
        var ext = filePath.substring(extStart, filePath.length).toUpperCase();
        if (ext == ".XLS" || ext == ".XLSX") {      	
        	fileloadon();
        }else{
        	func_artdialog("提示","请选择EXCEL文件！");
        }
	});
    function fileloadon() {
        var flag = false;
        $("#share_image").submit(function () {
            if (flag) {
                return;
            }
            flag = true;
            $("#share_image").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/ser/auditingMedicine/fileUpload",
                data: {"typename": "filepath"},
                success: function (data) {
                	if(data.status == 200){
                		path=data.data;
                		searchExcel(data.data);
                	}else{
                		func_artdialog("提示","导入失败！");
                	}                 
                },
                error: function (msg) {
                    func_artdialog("提示",msg);
                }
            });
            return false;
        });
        $("#share_image").submit();
    }
    function func_artdialog(name, value) {
        var d = dialog({
            title: name,
            fixed: true,
            width: 400,
            height: 100,
            content: "<center style='font-size:20px; line-height:100px;'>" + value + "</center>",
            okValue: "确定",
            ok: function () {
                return true;
            }
        });
        d.show();
    }
    //读取excel
    function searchExcel(path){
    	var pathUrl="<%=path%>/ser/auditingMedicine/readTitleExcel";
    	var option="";
    	$.ajax({
    		url:pathUrl,
    		type:"post",
			async:false,
			data:{"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid,
        		"path":path
        	},
			success:function(data){
				if(data.status == 200){
					for(var i=0;i<data.data.length;i++){
						option+="<option value="+i+">"+data.data[i]+"</option>";
					}
					option+="<option value=''>没有匹配</option>";
					$("#name").html(option);
			    	$("#commonName").html(option);
			   		$("#spec").html(option);
			   		$("#companyName").html(option);
			   		$("#barCode").html(option);
			   		$("#numberApproval").html(option);
			   		$("#goodsId").html(option);
			   		$("#importData").attr("style","display:block");
				}else{
                    func_artdialog("提示", "读取文件失败！");
				}
			}
    	});
    }
    //把excel数据插入表中
    $("#commit").click(function(){
    	var arrays = new Array();
    	arrays[0]=$("#name").val();
    	arrays[1]=$("#commonName").val();
   		arrays[2]=$("#spec").val();
   		arrays[3]=$("#companyName").val();
   		arrays[4]=$("#barCode").val();
   		arrays[5]=$("#numberApproval").val();
   		arrays[6]=$("#goodsId").val();
   		//console.log(JSON.stringify(arrays)); 
		var addUrl="<%=path%>/ser/auditingMedicine/addAuditingMedicine";
		$.ajax({
			url:addUrl,
    		type:"post",
			async:true,
			data:{"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid,
        		"path":path,
        		"arrays":JSON.stringify(arrays)
        	},
        	success:function(data){
        		swal({
					  title: "导入成功！",
					  type: 'success',
					  showCancelButton: false,
					  showConfirmButton: true,
					  showLoaderOnConfirm:true,
				}).then(function(){
					if(data.status == 200){
	        			$("#importData").attr("style","display:none");
	        			getDataList();
	        		}else{
	        			func_artdialog("提示",data.message);
	        		}       			
				});        		
        	},beforeSend: function () {
				 swal({
					  title: "正在处理...请稍后！",
					  type: 'info',
					  showCancelButton: false,
					  showConfirmButton: false,
					  showLoaderOnConfirm:true,
					  allowOutsideClick:false,
					  allowEscapeKey:false
				})
		    }
		});
    });   
 	//查询所有基础数据
    function getDataList(){
		$("#ignore").attr("style","margin-left: 130px;width: 170px;");
    	$("#marryTable").attr("style","display:block");
    	$("#batch").attr("style","margin-left: 130px;width: 80px;");
    	//查询出来未处理的数据
    	var status=0;
    	var url = "<%=path%>/ser/auditingMedicine/findAuditingMedicine";
    	$.ajax({url:url,
    		type:"post",
			async:false,
    		data:{
    		"access_token" : access_token,
 			"cid" : cid,
 			"uid" : uid,
 			"pageStart" : startIndex,
 			"pageSize" : pageSize ,
 			"status":status
    	},
    	success:function(data){
    		if(data.status == 200){
    			page(data.totalCount);
    			tableData(data.data);
    		}else if(data.error_code == 1){
    			func_artdialog("提示",data.message);
    		}
    	  }
    	});
    } 
 	//加载table的数据
 	function tableData(data){
 		var html ="";
 		var goodsName=null;
 		var commonName=null;
 		var spec=null;
 		var companyName=null;
 		var numberApproval=null;
 		var barCode=null;
 		var id=null;
 		for(var i=0;i<data.length;i++){
 			html+="<tr>";
 			var option="";
 			if(data[i].id!=null&&typeof(data[i].id!="undefined")){
 				id=data[i].id;
 				option+="<td name='"+id+"'>"+id+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsId!=null&&typeof(data[i].goodsId!="undefined")){
 	 			option+="<td>"+data[i].goodsId+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].barCode!=null&&typeof(data[i].barCode!="undefined")){
 				barCode=data[i].barCode;
 	 			option+="<td>"+barCode+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsName!=null&&typeof(data[i].goodsName!="undefined")){
 				goodsName=data[i].goodsName;
 				commonName=data[i].commonName;
 	 			option+="<td>"+goodsName+"/"+commonName+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].spec!=null&&typeof(data[i].spec!="undefined")){
 				spec=data[i].spec;
 	 			option+="<td>"+spec+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].numberApproval!=null&&typeof(data[i].numberApproval!="undefined")){
 				numberApproval=data[i].numberApproval;
 	 			option+="<td>"+numberApproval+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].companyName!=null&&typeof(data[i].companyName!="undefined")){
 				companyName=data[i].companyName;
 				option+="<td>"+companyName+"</td>";			
 			}else{
 				option+="<td></td>";
 			}
 			html+=option;
 			html+="<td><input type='button' class='uploadBtn' onclick='ignore("+id+")' value='忽略'></td>";
 			html+="</tr>";
 			 var searOption=auditingMedicine(id,barCode,numberApproval);
 			if(searOption==""||searOption==null){
 				html+="<tr style='color:blue'>";
 				html+=option;
 	 			html+="<td><input type='button' class='uploadBtn' onclick='submit("+id+",3,"+id+")' value='提交'></td>";
 	 			html+="</tr>";
 			}else{
 				html+=searOption;
 			}		 
 		}
 		$("#tbody").html(html);
 	}
 	//匹配药品库，获得符合条件的匹配数据
 	function auditingMedicine(id,barCode,numberApproval){
 		var getListUrl="<%=path%>/ser/auditingMedicine/getMedicineList";
 		var option="";
 		$.ajax({
 			url:getListUrl,
    		type:"post",
			async:false,
			data:{"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid,
        		"barCode":barCode,
        		"numberApproval":numberApproval
        	},
        	success:function(data){       		
        		if(data.status == 200){
         			for(var i=0;i<data.data.data.length;i++){ 
         				var medicine=data.data.data[i];
         				var goodsCode="";
         				var barCode="";
         				var goodsName="";
         				var spec="";
         				var commonName="";
         				var numberApproval="";
         				var companyName="";
         				var flag=data.data.flag;
         	 			option+="<tr style='color:blue;' name='"+id+"'><td></td>";
         	 			if(typeof(medicine.goodsCode)!="undefined"){
         	 				goodsCode=medicine.goodsCode;
         	 			}
         	 			if(typeof(medicine.barCode)!="undefined"){
         	 				barCode=medicine.barCode;
         	 			}
         	 			if(typeof(medicine.goodsName)!="undefined"){
         	 				goodsName=medicine.goodsName;
         	 			}
         	 			if(typeof(medicine.commonName)!="undefined"){
         	 				commonName=medicine.commonName;
         	 			}
         	 			if(typeof(medicine.spec)!="undefined"){
         	 				spec=medicine.spec;
         	 			}
         	 			if(typeof(medicine.numberApproval)!="undefined"){
         	 				numberApproval=medicine.numberApproval;
         	 			}
         	 			if(typeof(medicine.companyName)!="undefined"){
         	 				companyName=medicine.companyName;
         	 			}
         	 			option+="<td>"+goodsCode+"</td>";
         	 	 		option+="<td>"+barCode+"</td>";
         	 	 		option+="<td>"+goodsName+"/"+commonName+"</td>";
         	 	 		option+="<td>"+spec+"</td>";
         	 	 		option+="<td>"+numberApproval+"</td>";
         	 	 		option+="<td>"+companyName+"</td>";
         	 			option+="<td><input type='button' class='uploadBtn' onclick='submit("+id+","+flag+","+medicine.id+")' value='提交'></td>";
         	 			option+="</tr>";
         	 		}
         		}
        	}
 		});
 		return option;
 	}
 	//忽略操作
 	function ignore(id){
 		$("td[name="+id+"]").parent().attr("style","display:none");
 		$("tr[name="+id+"]").attr("style","display:none");
 		var ignoreUrl="<%=path%>/ser/auditingMedicine/updateAuditingMedicine";
 		var status=3;
 		$.ajax({
 			url:ignoreUrl,
    		type:"post",
			async:false,
			data:{
	 			"access_token" : access_token,
	    		"cid" : cid,
	    		"uid" : uid,
	    		"status":status,
	    		"id":id},
	    	success:function(data){
	    		console.log(data);
	    	},
	    	error:function(){
	    		console.log("失败！");
	    	}
	    });
 	}
 	function batchMatching(){ 
 		var url="<%=path%>/ser/auditingMedicine/batchMatching";
 		$.ajax({
 			url:url,
    		type:"post",
			async:true,			
	    	success:function(data){
	    		swal({
					  title: "处理完成！",
					  type: 'success',
					  showCancelButton: false,
					  showConfirmButton: true,
					  showLoaderOnConfirm:true,
				}).then(function(){
		    			getDataList();  			
				});  
	    		
	    	},beforeSend: function () {
				 swal({
					  title: "正在处理...请稍后！",
					  type: 'info',
					  showCancelButton: false,
					  showConfirmButton: false,
					  showLoaderOnConfirm:true,
					  allowOutsideClick:false,
					  allowEscapeKey:false
				})
		    }
	    });	  			
 	}
 	function ignoreNow(){
 		$("#tbody").find("tr").each(function(){
 			var td=$(this).children();
 			var id=td.attr("name");
 			if(typeof(id)!="undefined"){
 				ignore(id);
 			}
 		});
 		getDataList();
 		var speed=200;//滑动的速度
        $('body').animate({ scrollTop: 0 }, speed);
 	}
 	function ignoreAll(){
 		swal({
			  title: '你确定要忽略吗?',
			  text: "忽略本页之后可以在回收站查看",
			  type: 'warning',
			  showCancelButton: true,
			  confirmButtonColor: '#d33',
			  cancelButtonColor: '#3085d6',
			  confirmButtonText: "忽略",
			  cancelButtonText:"取消"
			}).then(function(){
				ignoreNow();
			})
 	}
 	//提交到审核上传
 	function submit(id,flag,goodsId){
 		$("td[name="+id+"]").parent().attr("style","display:none");
 		$("tr[name="+id+"]").attr("style","display:none");
 		var ignoreUrl="<%=path%>/ser/auditingMedicine/updateAuditingMedicine";
 		var status=1;
 		var medicineId=null;
 		var instructionId=null;
 		//flag--- 0基准库数据，1说明书中的数据
 		if(flag==0){
 			medicineId=goodsId;
 		}else if(flag==1){
 			instructionId=goodsId;
 		}
 		$.ajax({
 			url:ignoreUrl,
    		type:"post",
			async:false,
			data:{
	 			"access_token" : access_token,
	    		"cid" : cid,
	    		"uid" : uid,
	    		"status":status,
	    		"id":id,
	    		"medicineId":medicineId,
	    		"instructionId":instructionId},
	    	success:function(data){
	    		console.log(data);
	    	},
	    	error:function(){
	    		console.log("失败！");
	    	}
	    });
 	}
 	/* function medicineListHtml(data){
 		console.log(data);
 		var option="";
 		if(data.status == 200){
 			for(var i=0;i<data.data.length;i++){ 				
 				var medicine=data.data[i].medicine;
 				console.log(medicine);
 	 			option+="<tr style='color:blue;'><td></td>";
 	 	 		option+="<td>"+medicine.id+"</td>";
 	 	 		option+="<td></td>";
 	 	 		option+="<td>"+medicine.medicineName+"/"+medicine.commonName+"</td>";
 	 	 		option+="<td></td>";
 	 	 		option+="<td>"+medicine.numberApproval+"</td>";
 	 	 		option+="<td>"+medicine.company_name+"</td>";
 	 			option+="<td><input type='button' class='uploadBtn' id='submit' value='提交'></td>";
 	 			option+="</tr>";
 	 		}
 		}		
 		return option;
 	} */
 	 /* 分页 */
    $(".m_xpages select").change(function(){
 		pageSize = Number($(this).val());		
 		getDataList();
 	});
 	
    $(".m_xpages a.prev").click(function(){	 		
 		$('.next').html('<font color="black">下一页</font>');
 		if(currentPage > 1){
 			currentPage--;
 			startIndex -= pageSize;	 
 			if(currentPage == 1){
	 			$('.prev').html('<font color="#E0E0E0">上一页</font>');
 			}
 			getDataList();
 		}
 	});
 	$(".m_xpages a.next").click(function(){
 		$('.prev').html('<font color="black">上一页</font>'); 
 		if(currentPage < pageCount){
 			currentPage++;
 			startIndex += pageSize;
 			if(currentPage == pageCount){
	 			$('.next').html('<font color="#E0E0E0">下一页</font>');
	 		}
 			getDataList();
 		}
 	});
 	
 	$(".m_xpages :text").keyup(function(e){
		if(e.keyCode==13){
			var pageGo = $(this).val();
			if(/^[0-9]+$/.test(pageGo)){
				pageGo = Number(pageGo);
				if(pageGo<1 || pageGo>pageCount){
					func_artdialog("提示",'页数不存在！');
				}else if(pageGo != currentPage){
					startIndex = (pageGo -1) * pageSize ;	
					getDataList();
				}
			}else{
				func_artdialog("提示","请输入合法页数！");
			}
		}
	});
    function page(totalCount) {
		pageCount = totalCount/pageSize;
		var count=totalCount % pageSize;
 		if (count>0){
 			pageCount++;
 		}
 		pageCount = parseInt(pageCount);
 		currentPage =  startIndex / pageSize + 1;
 		currentPage = parseInt(currentPage);
 		
 		if(currentPage == 1){
 			$(".prev").addClass("pageDisable");
 		}else{
 			$(".prev").removeClass("pageDisable");
 		}
 		
 		if(currentPage == pageCount || pageCount == 0){
 			$(".next").addClass("pageDisable");
 		}else{
 			$(".next").removeClass("pageDisable");
 		}
 		
 		$(".m_xpages>.mian>span:eq(1)").text('共'+totalCount+'条');
 		$(".m_xpages>.mian>span:eq(2)").text(currentPage+'/'+pageCount+'页');
	}
   	/***************************************************************************/
    /**审核上传的相关js**/
    //获取需要审核的数据
    function getAuditingData(data){
    	var html ="";
 		var goodsName=null;
 		var commonName=null;
 		var spec=null;
 		var companyName=null;
 		var id=null;
 		for(var i=0;i<data.length;i++){
 			html+="<tr>";
 			var option="";
 			if(data[i].id!=null&&typeof(data[i].id!="undefined")){
 				id=data[i].id;
 				option+="<td name='audit"+id+"'>"+id+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsId!=null&&typeof(data[i].goodsId!="undefined")){
 	 			option+="<td>"+data[i].goodsId+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].barCode!=null&&typeof(data[i].barCode!="undefined")){
 	 			option+="<td>"+data[i].barCode+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsName!=null&&typeof(data[i].goodsName!="undefined")){
 				goodsName=data[i].goodsName;
 				commonName=data[i].commonName;
 	 			option+="<td>"+goodsName+"/"+commonName+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].spec!=null&&typeof(data[i].spec!="undefined")){
 				spec=data[i].spec;
 	 			option+="<td>"+spec+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].numberApproval!=null&&typeof(data[i].numberApproval!="undefined")){
 	 			option+="<td>"+data[i].numberApproval+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].companyName!=null&&typeof(data[i].companyName!="undefined")){
 				companyName=data[i].companyName;
 				option+="<td>"+companyName+"</td>";			
 			}else{
 				option+="<td></td>";
 			}
 			html+=option;
 			html+="<td><input type='button' class='uploadBtn' onclick='cancel("+id+")' value='撤销'></td>";
 			html+="</tr>";
 			var searOption=getMedicine(id,data[i].medicineId);
 			if(searOption==""||searOption==null){
 				html+="<tr style='color:blue'>";
 	 			html+="<td name='audit"+id+"'><label class='col-sm-1 control-label'><input id='checkbox' type='checkbox' name='audit"+id+"'></label></td>";
 	 			if(data[i].goodsId!=null&&typeof(data[i].goodsId!="undefined")){
 	 				html+="<td>"+data[i].goodsId+"</td>";
 	 			}else{
 	 				html+="<td></td>";
 	 			}
 	 			if(data[i].barCode!=null&&typeof(data[i].barCode!="undefined")){
 	 				html+="<td>"+data[i].barCode+"</td>";
 	 			}else{
 	 				html+="<td></td>";
 	 			}
 	 			if(data[i].goodsName!=null&&typeof(data[i].goodsName!="undefined")){
 	 				goodsName=data[i].goodsName;
 	 				commonName=data[i].commonName;
 	 				html+="<td>"+goodsName+"/"+commonName+"</td>";
 	 			}else{
 	 				html+="<td></td>";
 	 			}
 	 			if(data[i].spec!=null&&typeof(data[i].spec!="undefined")){
 	 				spec=data[i].spec;
 	 				html+="<td>"+spec+"</td>";
 	 			}else{
 	 				html+="<td></td>";
 	 			}
 	 			if(data[i].numberApproval!=null&&typeof(data[i].numberApproval!="undefined")){
 	 				html+="<td>"+data[i].numberApproval+"</td>";
 	 			}else{
 	 				html+="<td></td>";
 	 			}
 	 			if(data[i].companyName!=null&&typeof(data[i].companyName!="undefined")){
 	 				companyName=data[i].companyName;
 	 				html+="<td>"+companyName+"</td>";			
 	 			}else{
 	 				html+="<td></td>";
 	 			}
 	 			html+="<td><input type='button' class='uploadBtn' onclick='upload("+id+")' value='提交'></td>";
 	 			html+="</tr>";
 			}else{
 				html+=searOption;
 			}		
 		}
 		$("#tbody1").html(html);
    	$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
   	}
  //查询所有基础数据
    function getDataList1(){
	  //查询出来通过人工匹配的数据
    	var status=1;
    	var url = "<%=path%>/ser/auditingMedicine/findAuditingMedicine";
    	$.ajax({url:url,
    		type:"post",
			async:false,
    		data:{
    		"access_token" : access_token,
 			"cid" : cid,
 			"uid" : uid,
 			"pageStart" : startIndex,
 			"pageSize" : pageSize ,
 			"status":status
    	},
    	success:function(data){
    		if(data.status == 200){
    			page1(data.totalCount);
    			getAuditingData(data.data);
    		}else if(data.error_code == 1){
    			func_artdialog("提示",data.message);
    		}
    	  }
    	});
    } 
  //匹配药品库，获得符合条件的匹配数据
 	function getMedicine(id,medicineId){
 		var getListUrl="<%=path%>/ser/auditingMedicine/getMedicine";
 		var option="";
 		$.ajax({
 			url:getListUrl,
    		type:"post",
			async:false,
			data:{"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid,
        		"id":medicineId
        	},
        	success:function(data){
        		if(data.status == 200){
         				var medicine=data.data;
         	 			var goodsCode="";
         				var barCode="";
         				var goodsName="";
         				var spec="";
         				var commonName="";
         				var numberApproval="";
         				var companyName="";
         	 			option+="<tr style='color:blue;' >";  
         	 			option+="<td name='audit"+id+"'><label class='col-sm-1 control-label'><input id='checkbox' type='checkbox' name='audit"+id+"'></label></td>";
         	 			if(medicine.goodsCode!=null&&typeof(medicine.goodsCode)!="undefined"){
         	 				goodsCode=medicine.goodsCode;
         	 			}
         	 			if(typeof(medicine.barCode)!="undefined"){
         	 				barCode=medicine.barCode;
         	 			}
         	 			if(typeof(medicine.goodsName)!="undefined"){
         	 				goodsName=medicine.goodsName;
         	 			}
         	 			if(typeof(medicine.commonName)!="undefined"){
         	 				commonName=medicine.commonName;
         	 			}
         	 			if(typeof(medicine.spec)!="undefined"){
         	 				spec=medicine.spec;
         	 			}
         	 			if(typeof(medicine.numberApproval)!="undefined"){
         	 				numberApproval=medicine.numberApproval;
         	 			}
         	 			if(typeof(medicine.companyName)!="undefined"){
         	 				companyName=medicine.companyName;
         	 			}
         	 			option+="<td>"+goodsCode+"</td>";
         	 	 		option+="<td>"+barCode+"</td>";
         	 	 		option+="<td>"+goodsName+"/"+commonName+"</td>";
         	 	 		option+="<td>"+spec+"</td>";
         	 	 		option+="<td>"+numberApproval+"</td>";
         	 	 		option+="<td>"+companyName+"</td>";
         	 			option+="<td><input type='button' class='uploadBtn' onclick='upload("+id+")' value='上传'></td>";
         	 			option+="</tr>";
         		}
        	}
 		});
 		return option;
 	}
   	//撤销操作
   	function cancel(id){
   		$("td[name=audit"+id+"]").parent().attr("style","display:none");
 		$("tr[name=audit"+id+"]").attr("style","display:none");
 		var ignoreUrl="<%=path%>/ser/auditingMedicine/updateAuditingMedicine";
 		var status=0;
 		$.ajax({
 			url:ignoreUrl,
    		type:"post",
			async:false,
			data:{
	 			"access_token" : access_token,
	    		"cid" : cid,
	    		"uid" : uid,
	    		"status":status,
	    		"id":id},
	    	success:function(data){
	    		console.log(data);
	    	},
	    	error:function(){
	    		console.log("失败！");
	    	}
	    });
   	}
   	function cancelAll(){
   		swal({
			  title: "你确定要撤销吗？",
			  text: "撤销之后可以在数据匹配中查看",
			  type: 'warning',
			  showCancelButton: true,
			  confirmButtonColor: '#d33',
			  cancelButtonColor: '#3085d6',
			  confirmButtonText:"撤销",
			  cancelButtonText:"取消"
			}).then(function(){
				cancelLot();
			})
   	}
   	function cancelLot(){
   		$("#tbody1").find("tr").each(function(){
 			var td=$(this).children();
 			var id=td.attr("name");
 			if(typeof(id)!="undefined"){
 				id=id.replace("audit","");
 				cancel(id);
 			}
 		});
 		getDataList1();
 		var speed=200;//滑动的速度
        $('body').animate({ scrollTop: 0 }, speed);
   	}
   	function checkAll(){
   		$("input[id='checkbox'").each(function(){ 
 			if($(this).prop("checked")==false){
 				$(this).prop("checked",true);
 		    	$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
 			}else{
 				$(this).prop("checked",false);
 		    	$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
 			}	
 		});
   	}
  	//上传操作
   	function upload(id){
   		$("td[name=audit"+id+"]").parent().attr("style","display:none");
 		$("tr[name=audit"+id+"]").attr("style","display:none");
 		var uploadUrl="<%=path%>/ser/auditingMedicine/uploadSuccessData";
 		var status=2;
 		$.ajax({
 			url:uploadUrl,
    		type:"post",
			async:false,
			data:{
	 			"access_token" : access_token,
	    		"cid" : cid,
	    		"uid" : uid,
	    		"status":status,
	    		"id":id
	    		},
	    	success:function(data){
	    		console.log(data);
	    	},
	    	error:function(){
	    		console.log("失败！");
	    	}
	    });
   	}
  	function uploadAll(){
  		$("#tbody1").find("tr").each(function(){
 			var checkBox=$(this).children().children("label").children().children();
 			var id=checkBox.attr("name");
 			if(typeof(id)!="undefined"&&checkBox.is(":checked")){
 				id=id.replace("audit","");
 				upload(id);
 			}
 		});
 		getDataList1();
 		var speed=200;//滑动的速度
        $('body').animate({ scrollTop: 0 }, speed);
  	}
    /*审核上传分页操作*/
     /* 分页 */
    $(".m_xpages1 select").change(function(){
 		pageSize = Number($(this).val());		
 		getDataList1();
 	});
 	
    $(".m_xpages1 a.prev1").click(function(){	 		
 		$('.next1').html('<font color="black">下一页</font>');
 		if(currentPage > 1){
 			currentPage--;
 			startIndex -= pageSize;	 
 			if(currentPage == 1){
	 			$('.prev1').html('<font color="#E0E0E0">上一页</font>');
 			}
 			getDataList1();
 		}
 	});
 	$(".m_xpages1 a.next1").click(function(){
 		$('.prev1').html('<font color="black">上一页</font>'); 
 		if(currentPage < pageCount){
 			currentPage++;
 			startIndex += pageSize;
 			if(currentPage == pageCount){
	 			$('.next1').html('<font color="#E0E0E0">下一页</font>');
	 		}
 			getDataList1();
 		}
 	});
 	
 	$(".m_xpages1 :text").keyup(function(e){
		if(e.keyCode==13){
			var pageGo = $(this).val();
			if(/^[0-9]+$/.test(pageGo)){
				pageGo = Number(pageGo);
				if(pageGo<1 || pageGo>pageCount){
					func_artdialog("提示",'页数不存在！');
				}else if(pageGo != currentPage){
					startIndex = (pageGo -1) * pageSize ;	
					getDataList1();
				}
			}else{
				func_artdialog("提示","请输入合法页数！");
			}
		}
	});
    function page1(totalCount) {
		pageCount = totalCount/pageSize;
		var count=totalCount % pageSize;
 		if (count>0){
 			pageCount++;
 		}
 		pageCount = parseInt(pageCount);
 		currentPage =  startIndex / pageSize + 1;
 		currentPage = parseInt(currentPage);
 		
 		if(currentPage == 1){
 			$(".prev1").addClass("pageDisable");
 		}else{
 			$(".prev1").removeClass("pageDisable");
 		}
 		
 		if(currentPage == pageCount || pageCount == 0){
 			$(".next1").addClass("pageDisable");
 		}else{
 			$(".next1").removeClass("pageDisable");
 		}
 		
 		$(".m_xpages1>.mian>span:eq(1)").text('共'+totalCount+'条');
 		$(".m_xpages1>.mian>span:eq(2)").text(currentPage+'/'+pageCount+'页');
	}
    /*******************************************************************/
    /**上传成功**/
    function getSuccessData(data){
    	var html ="";
 		var goodsName=null;
 		var commonName=null;
 		var spec=null;
 		var companyName=null;
 		var id=null;
 		for(var i=0;i<data.length;i++){
 			html+="<tr>";
 			var option="";
 			if(data[i].id!=null&&typeof(data[i].id!="undefined")){
 				id=data[i].id;
 				option+="<td name='callback"+id+"'>"+id+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsId!=null&&typeof(data[i].goodsId!="undefined")){
 	 			option+="<td>"+data[i].goodsId+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].barCode!=null&&typeof(data[i].barCode!="undefined")){
 	 			option+="<td>"+data[i].barCode+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsName!=null&&typeof(data[i].goodsName!="undefined")){
 				goodsName=data[i].goodsName;
 				commonName=data[i].commonName;
 	 			option+="<td>"+goodsName+"/"+commonName+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].spec!=null&&typeof(data[i].spec!="undefined")){
 				spec=data[i].spec;
 	 			option+="<td>"+spec+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].numberApproval!=null&&typeof(data[i].numberApproval!="undefined")){
 	 			option+="<td>"+data[i].numberApproval+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].companyName!=null&&typeof(data[i].companyName!="undefined")){
 				companyName=data[i].companyName;
 				option+="<td>"+companyName+"</td>";			
 			}else{
 				option+="<td></td>";
 			}
 			html+=option;
 			html+="</tr>";	
 		}
 		$("#tbody2").html(html);
   	}
  //查询所有基础数据
    function getDataList2(){
	  //查询出来通过人工匹配的数据
    	var status=2;
    	var url = "<%=path%>/ser/auditingMedicine/findAuditingMedicine";
    	$.ajax({url:url,
    		type:"post",
			async:false,
    		data:{
    		"access_token" : access_token,
 			"cid" : cid,
 			"uid" : uid,
 			"pageStart" : startIndex,
 			"pageSize" : pageSize ,
 			"status":status
    	},
    	success:function(data){
    		if(data.status == 200){
    			page2(data.totalCount);
    			getSuccessData(data.data);
    		}else if(data.error_code == 1){
    			func_artdialog("提示",data.message);
    		}
    	  }
    	});
    } 
    /*上传成功分页操作*/
    /* 分页 */
   $(".m_xpages2 select").change(function(){
		pageSize = Number($(this).val());		
		getDataList2();
	});
	
   $(".m_xpages2 a.prev2").click(function(){	 		
		$('.next2').html('<font color="black">下一页</font>');
		if(currentPage > 1){
			currentPage--;
			startIndex -= pageSize;	 
			if(currentPage == 1){
	 			$('.prev2').html('<font color="#E0E0E0">上一页</font>');
			}
			getDataList2();
		}
	});
	$(".m_xpages2 a.next2").click(function(){
		$('.prev2').html('<font color="black">上一页</font>'); 
		if(currentPage < pageCount){
			currentPage++;
			startIndex += pageSize;
			if(currentPage == pageCount){
	 			$('.next3').html('<font color="#E0E0E0">下一页</font>');
	 		}
			getDataList2();
		}
	});
	
	$(".m_xpages2 :text").keyup(function(e){
		if(e.keyCode==13){
			var pageGo = $(this).val();
			if(/^[0-9]+$/.test(pageGo)){
				pageGo = Number(pageGo);
				if(pageGo<1 || pageGo>pageCount){
					func_artdialog("提示",'页数不存在！');
				}else if(pageGo != currentPage){
					startIndex = (pageGo -1) * pageSize ;	
					getDataList2();
				}
			}else{
				func_artdialog("提示","请输入合法页数！");
			}
		}
	});
   function page2(totalCount) {
		pageCount = totalCount/pageSize;
		var count=totalCount % pageSize;
		if (count>0){
			pageCount++;
		}
		pageCount = parseInt(pageCount);
		currentPage =  startIndex / pageSize + 1;
		currentPage = parseInt(currentPage);
		
		if(currentPage == 1){
			$(".prev2").addClass("pageDisable");
		}else{
			$(".prev2").removeClass("pageDisable");
		}
		
		if(currentPage == pageCount || pageCount == 0){
			$(".next2").addClass("pageDisable");
		}else{
			$(".next2").removeClass("pageDisable");
		}
		
		$(".m_xpages2>.mian>span:eq(1)").text('共'+totalCount+'条');
		$(".m_xpages2>.mian>span:eq(2)").text(currentPage+'/'+pageCount+'页');
	}
    
    /*******************************************************************/
    /**回收站**/
    function getCallbackData(data){
    	var html ="";
 		var goodsName=null;
 		var commonName=null;
 		var spec=null;
 		var companyName=null;
 		var id=null;
 		var numberApproval=null;
 		var barCode=null;
 		for(var i=0;i<data.length;i++){
 			html+="<tr>";
 			var option="";
 			if(data[i].id!=null&&typeof(data[i].id!="undefined")){
 				id=data[i].id;
 				option+="<td name='callback"+id+"'>"+id+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsId!=null&&typeof(data[i].goodsId!="undefined")){
 	 			option+="<td>"+data[i].goodsId+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].barCode!=null&&typeof(data[i].barCode!="undefined")){
 				barCode=data[i].barCode;
 	 			option+="<td>"+barCode+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].goodsName!=null&&typeof(data[i].goodsName!="undefined")){
 				goodsName=data[i].goodsName;
 				commonName=data[i].commonName;
 	 			option+="<td>"+goodsName+"/"+commonName+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].spec!=null&&typeof(data[i].spec!="undefined")){
 				spec=data[i].spec;
 	 			option+="<td>"+spec+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].numberApproval!=null&&typeof(data[i].numberApproval!="undefined")){
 				numberApproval=data[i].numberApproval;
 	 			option+="<td>"+numberApproval+"</td>";
 			}else{
 				option+="<td></td>";
 			}
 			if(data[i].companyName!=null&&typeof(data[i].companyName!="undefined")){
 				companyName=data[i].companyName;
 				option+="<td>"+companyName+"</td>";			
 			}else{
 				option+="<td></td>";
 			}
 			html+=option;
 			html+="<td><input type='button' class='uploadBtn' onclick='callback("+id+")' value='撤销'></td>";
 			html+="</tr>";
 			var searOption=callBackAuditingMedicine(id,barCode,numberApproval);
 			if(searOption==""||searOption==null){
 				html+="<tr style='color:blue'>";
 				html+=option;
 	 			html+="<td></td>";
 	 			html+="</tr>";
 			}else{
 				html+=searOption;
 			}
 		}
 		$("#tbody3").html(html);
   	}
    function callBackAuditingMedicine(id,barCode,numberApproval){
 		var getListUrl="<%=path%>/ser/auditingMedicine/getMedicineList";
 		var option="";
 		$.ajax({
 			url:getListUrl,
    		type:"post",
			async:false,
			data:{"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid,
        		"barCode":barCode,
        		"numberApproval":numberApproval
        	},
        	success:function(data){       		
        		if(data.status == 200){
         			for(var i=0;i<data.data.data.length;i++){ 
         				var medicine=data.data.data[i];
         				var goodsCode="";
         				var barCode="";
         				var goodsName="";
         				var spec="";
         				var commonName="";
         				var numberApproval="";
         				var companyName="";
         				var flag=data.data.flag;
         	 			option+="<tr style='color:blue;' name='callback"+id+"'><td></td>";
         	 			if(typeof(medicine.goodsCode)!="undefined"){
         	 				goodsCode=medicine.goodsCode;
         	 			}
         	 			if(typeof(medicine.barCode)!="undefined"){
         	 				barCode=medicine.barCode;
         	 			}
         	 			if(typeof(medicine.goodsName)!="undefined"){
         	 				goodsName=medicine.goodsName;
         	 			}
         	 			if(typeof(medicine.commonName)!="undefined"){
         	 				commonName=medicine.commonName;
         	 			}
         	 			if(typeof(medicine.spec)!="undefined"){
         	 				spec=medicine.spec;
         	 			}
         	 			if(typeof(medicine.numberApproval)!="undefined"){
         	 				numberApproval=medicine.numberApproval;
         	 			}
         	 			if(typeof(medicine.companyName)!="undefined"){
         	 				companyName=medicine.companyName;
         	 			}
         	 			option+="<td>"+goodsCode+"</td>";
         	 	 		option+="<td>"+barCode+"</td>";
         	 	 		option+="<td>"+goodsName+"/"+commonName+"</td>";
         	 	 		option+="<td>"+spec+"</td>";
         	 	 		option+="<td>"+numberApproval+"</td>";
         	 	 		option+="<td>"+companyName+"</td>";
         	 			option+="<td></td>";
         	 			option+="</tr>";
         	 		}
         		}
        	}
 		});
 		return option;
 	}
  //查询所有基础数据
    function getDataList3(){
	  //查询出来通过人工匹配的数据
    	var status=3;
    	var url = "<%=path%>/ser/auditingMedicine/findAuditingMedicine";
    	$.ajax({url:url,
    		type:"post",
			async:false,
    		data:{
    		"access_token" : access_token,
 			"cid" : cid,
 			"uid" : uid,
 			"pageStart" : startIndex,
 			"pageSize" : pageSize ,
 			"status":status
    	},
    	success:function(data){
    		if(data.status == 200){
    			page3(data.totalCount);
    			getCallbackData(data.data);
    		}else if(data.error_code == 1){
    			func_artdialog("提示",data.message);
    		}
    	  }
    	});
    } 
   	//撤销操作
   	function callback(id){
   		$("td[name=callback"+id+"]").parent().attr("style","display:none");
 		$("tr[name=callback"+id+"]").attr("style","display:none");
 		var ignoreUrl="<%=path%>/ser/auditingMedicine/updateAuditingMedicine";
 		var status=0;
 		$.ajax({
 			url:ignoreUrl,
    		type:"post",
			async:false,
			data:{
	 			"access_token" : access_token,
	    		"cid" : cid,
	    		"uid" : uid,
	    		"status":status,
	    		"id":id},
	    	success:function(data){
	    		console.log(data);
	    	},
	    	error:function(){
	    		console.log("失败！");
	    	}
	    });
   	} 
   	function del(id){
   		$("td[name=callback"+id+"]").parent().attr("style","display:none");
 		$("tr[name=callback"+id+"]").attr("style","display:none");
 		var ignoreUrl="<%=path%>/ser/auditingMedicine/updateAuditingMedicine";
 		var status=4; 
 		$.ajax({
 			url:ignoreUrl,
    		type:"post",
			async:false,
			data:{
	 			"access_token" : access_token,
	    		"cid" : cid,
	    		"uid" : uid,
	    		"status":status,
	    		"id":id},
	    	success:function(data){
	    		console.log(data);
	    	},
	    	error:function(){
	    		console.log("失败！");
	    	}
	    });
   	}
   	function deleteAll(){
   			$("#tbody3").find("tr").each(function(){
   	 			var td=$(this).children();
   	 			var id=td.attr("name");
   	 			if(typeof(id)!="undefined"){
   	 				id=id.replace("callback","");
   	 				del(id);
   	 			}
   	 		});
   	 		getDataList3();
   	 		var speed=200;//滑动的速度
   	        $('body').animate({ scrollTop: 0 }, speed);	 					
   	}
   	function deleteDialog(){
   		swal({
			  title: "你确定要删除吗？",
			  text: "删除之后无法查看！",
			  type: 'warning',
			  showCancelButton: true,
			  confirmButtonColor: '#d33',
			  cancelButtonColor: '#3085d6',
			  confirmButtonText:"删除",
			  cancelButtonText:"取消"
			}).then(function(){
				deleteAll();
			})
   	}
    /*回收站分页操作*/
    /* 分页 */
   $(".m_xpages3 select").change(function(){
		pageSize = Number($(this).val());		
		getDataList3();
	});
	
   $(".m_xpages3 a.prev3").click(function(){	 		
		$('.next3').html('<font color="black">下一页</font>');
		if(currentPage > 1){
			currentPage--;
			startIndex -= pageSize;	 
			if(currentPage == 1){
	 			$('.prev3').html('<font color="#E0E0E0">上一页</font>');
			}
			getDataList3();
		}
	});
	$(".m_xpages3 a.next3").click(function(){
		$('.prev3').html('<font color="black">上一页</font>'); 
		if(currentPage < pageCount){
			currentPage++;
			startIndex += pageSize;
			if(currentPage == pageCount){
	 			$('.next3').html('<font color="#E0E0E0">下一页</font>');
	 		}
			getDataList3();
		}
	});
	
	$(".m_xpages3 :text").keyup(function(e){
		if(e.keyCode==13){
			var pageGo = $(this).val();
			if(/^[0-9]+$/.test(pageGo)){
				pageGo = Number(pageGo);
				if(pageGo<1 || pageGo>pageCount){
					func_artdialog("提示",'页数不存在！');
				}else if(pageGo != currentPage){
					startIndex = (pageGo -1) * pageSize ;	
					getDataList3();
				}
			}else{
				func_artdialog("提示","请输入合法页数！");
			}
		}
	});
   function page3(totalCount) {
		pageCount = totalCount/pageSize;
		var count=totalCount % pageSize;
		if (count>0){
			pageCount++;
		}
		pageCount = parseInt(pageCount);
		currentPage =  startIndex / pageSize + 1;
		currentPage = parseInt(currentPage);
		
		if(currentPage == 1){
			$(".prev3").addClass("pageDisable");
		}else{
			$(".prev3").removeClass("pageDisable");
		}
		
		if(currentPage == pageCount || pageCount == 0){
			$(".next3").addClass("pageDisable");
		}else{
			$(".next3").removeClass("pageDisable");
		}
		
		$(".m_xpages3>.mian>span:eq(1)").text('共'+totalCount+'条');
		$(".m_xpages3>.mian>span:eq(2)").text(currentPage+'/'+pageCount+'页');
	}
    //判断字符串是否为空
	function StringEmpty(content) {
		if (content == undefined || content == "" || content == null) {
			return false;
		} else {
			return true;
		}
	}
    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>
</html>
